<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 仅仅反转字母 -->
    <script>
      var rever = function (S) {
        let stk = []
        let out = ''

        for (let i = 0; i < S.length; i++) {
          if ((S.charCodeAt(i) >= 'A'.charCodeAt(0) && S.charCodeAt(i) <= 'Z'.charCodeAt(0)) || (S.charCodeAt(i) >= 'a'.charCodeAt(0) && S.charCodeAt(i) <= 'z'.charCodeAt(0))) {
            stk.push(S.substring(i, i + 1))
          }
        }
        for (let i = 0; i < S.length; i++) {
          if ((S.charCodeAt(i) >= 'A'.charCodeAt(0) && S.charCodeAt(i) <= 'Z'.charCodeAt(0)) || (S.charCodeAt(i) >= 'a'.charCodeAt(0) && S.charCodeAt(i) <= 'z'.charCodeAt(0))) {
            out = out + stk.pop()
          } else {
            out = out + S.substring(i, i + 1)
          }
        }

        return out
      }
      // console.log(rever('ab-cd'))
      // console.log(rever('a-bC-dEf-ghIj'))
      console.log(rever('Test1ng-Leet=code-Q!'))
    </script>
  </body>
</html>
